package com.wlhse.controller;

import com.wlhse.dto.getDto.EmloyeeGetDto;
import com.wlhse.dto.inDto.CheckRecordInDto;
import com.wlhse.dto.inDto.ProblemImportInDto1;
import com.wlhse.dto.outDto.ProblemImportDto;
import com.wlhse.entity.CheckRecordPojo_cys;
import com.wlhse.service.ProblemImportService1;
import com.wlhse.service.ProblemImportService_cys;
import com.wlhse.util.GetCurrentUserIdUtil;
import com.wlhse.util.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController("ProblemController_cys")
@RequestMapping("/api/v1")
//问题录入
public class ProblemController_cys {

    @Resource
    private ProblemImportService_cys problemImportService_cys;
    @Resource
    private GetCurrentUserIdUtil getCurrentUserIdUtil;


//    @RequestMapping(value = "/gist/{checklistitemID}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
//    public String returnGist(@PathVariable int checklistitemID) {
//        return problemImportService_cys.listGist(checklistitemID);
//    }

    @RequestMapping(value = "/hse_factor/{checklistitemID}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String returnHseFactor(@PathVariable int checklistitemID) {
        return problemImportService_cys.listHseFactor(checklistitemID);
    }

    @RequestMapping(value = "/dict_rectification", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String returnDictRectification() {
        return problemImportService_cys.listDictRectification();
    }

    @RequestMapping(value = "/dict_rect_effect", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String returnDictRectEffect() {
        return problemImportService_cys.listDictRectEffect();
    }

    @RequestMapping(value = "/dict_lostscore", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String returnDictLostscore() {
        return problemImportService_cys.listDictLostScore();
    }

    @RequestMapping(value = "/dict_penalty", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String returnDictPenalty() {
        return problemImportService_cys.listDictPenalty();
    }


    //问题录入
    @RequestMapping(value = "/checkrecord_add", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public R newAddProblemImportDto(@RequestBody(required = false) CheckRecordPojo_cys checkRecordPojo, HttpServletRequest request) {
        return problemImportService_cys.newInsertProblemImport(checkRecordPojo,getCurrentUserIdUtil.getUserId(request));
    }

    @RequestMapping(value = "/checkrecord_employees", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getEmployees(@ModelAttribute EmloyeeGetDto dto, HttpServletRequest request) {
        Integer userId = getCurrentUserIdUtil.getUserId(request);
        return problemImportService_cys.getAllEmployeeDto(dto, userId);
    }

    //问题修改
    @RequestMapping(value = "/checkrecord_update/{id}", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public R updateProblemImportDto(@RequestBody(required = false) CheckRecordPojo_cys checkRecordPojo, @PathVariable("id") Integer id, HttpServletRequest request) {
        checkRecordPojo.setCheckRecordID(id);
        return problemImportService_cys.updateProblemImport(checkRecordPojo,getCurrentUserIdUtil.getUserId(request));
    }

    //查询未审核
    @RequestMapping(value = "/query_noveriy", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getVerifyCheckRecordMine(@ModelAttribute CheckRecordInDto checkRecordInDto, HttpServletRequest request) {
        checkRecordInDto.setVerifyPersonEmpID(getCurrentUserIdUtil.getUserId(request));
        return problemImportService_cys.queryNoveriy(checkRecordInDto);
    }

    //查询所有检查项
    @RequestMapping(value = "/query_checkitem", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getCheckListItem() {
        return problemImportService_cys.queryCheckListItem();
    }

    //根据id查询检查项
    @RequestMapping(value = "/query_checkitem_byid/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getCheckListItemByid(@PathVariable("id") int id, HttpServletRequest request) {
        return problemImportService_cys.getCheckListItemByid(id);
    }

    //查询检查表和检查表项
    @RequestMapping(value = "/query_checkList_item", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String getCheckList_Item(HttpServletRequest request) {
        return problemImportService_cys.getCheckList_Item();
    }
}
